#include "bsp_seg.h"

void Seg_Tran(unsigned char *Seg_Code,unsigned char *Seg_Buf){

	unsigned char i;
	unsigned char j = 0;
	unsigned char temp;
	
	for(i = 0; i < 8; i++,j++){
	
		switch(Seg_Buf[j]){
		
			case '0': temp = 0xc0; break;
			case '1': temp = 0xf9; break;
			case '2': temp = 0xa4; break;
			case '3': temp = 0xb0; break;
			case '4': temp = 0x99; break;
			case '5': temp = 0x92; break;
			case '6': temp = 0x82; break;
			case '7': temp = 0xf8; break;
			case '8': temp = 0x80; break;
			case '9': temp = 0x90; break;
			
			case '-': temp = 0xbf; break;
			case ' ': temp = 0xff; break;
			default : temp = 0xff;
		}
		if(Seg_Buf[j+1] == '.'){
			
			temp &= 0x7f;
			j++;
		}
		Seg_Code[i] = temp;
	}
}

void Seg_Disp(unsigned char *Seg_Code,unsigned char Seg_Pos){
	
	P0_OUT(0xff,7);
	P0_OUT(1<<Seg_Pos,6);
	P0_OUT(Seg_Code[Seg_Pos],7);
}


